﻿using APP.HELPER.Data.Helper;
using System; using Extra.ERP;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;

namespace HRM.CORE
{
    public class DIC_PIT
    {
        private decimal m_FromMoney;
        private Guid m_PITID;
        private decimal m_TaxProgressive;
        private double m_TaxRate;
        private int m_TaxStep;
        private decimal m_ToMoney;

        public DIC_PIT()
        {
            this.m_PITID = Guid.NewGuid();
            this.m_TaxStep = 0;
            this.m_FromMoney = 0M;
            this.m_ToMoney = 0M;
            this.m_TaxProgressive = 0M;
            this.m_TaxRate = 0.0;
        }

        public DIC_PIT(Guid PITID, int TaxStep, decimal FromMoney, decimal ToMoney, decimal TaxProgressive, double TaxRate)
        {
            this.m_PITID = PITID;
            this.m_TaxStep = TaxStep;
            this.m_FromMoney = FromMoney;
            this.m_ToMoney = ToMoney;
            this.m_TaxProgressive = TaxProgressive;
            this.m_TaxRate = TaxRate;
        }

        public string Delete()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_PIT_Delete");
        }

        public string Get()
        {
            string str = "";
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("DIC_PIT_Get");
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_PITID = reader.GetGuid(reader.GetOrdinal("PITID"));
                    this.m_TaxStep = Convert.ToInt32(reader["TaxStep"]);
                    this.m_FromMoney = Convert.ToDecimal(reader["FromMoney"]);
                    this.m_ToMoney = Convert.ToDecimal(reader["ToMoney"]);
                    this.m_TaxProgressive = Convert.ToDecimal(reader["TaxProgressive"]);
                    this.m_TaxRate = Convert.ToDouble(reader["TaxRate"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("DIC_PIT_GetList");
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@PITID", "@TaxStep", "@FromMoney", "@ToMoney", "@TaxProgressive", "@TaxRate" };
            object[] myValues = new object[] { this.m_PITID, this.m_TaxStep, this.m_FromMoney, this.m_ToMoney, this.m_TaxProgressive, this.m_TaxRate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_PIT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@PITID", "@TaxStep", "@FromMoney", "@ToMoney", "@TaxProgressive", "@TaxRate" };
            object[] myValues = new object[] { this.m_PITID, this.m_TaxStep, this.m_FromMoney, this.m_ToMoney, this.m_TaxProgressive, this.m_TaxRate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_PIT_Insert", myParams, myValues);
        }

        public string Insert(Guid PITID, int TaxStep, decimal FromMoney, decimal ToMoney, decimal TaxProgressive, double TaxRate)
        {
            string[] myParams = new string[] { "@PITID", "@TaxStep", "@FromMoney", "@ToMoney", "@TaxProgressive", "@TaxRate" };
            object[] myValues = new object[] { PITID, TaxStep, FromMoney, ToMoney, TaxProgressive, TaxRate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("DIC_PIT_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid PITID, int TaxStep, decimal FromMoney, decimal ToMoney, decimal TaxProgressive, double TaxRate)
        {
            string[] myParams = new string[] { "@PITID", "@TaxStep", "@FromMoney", "@ToMoney", "@TaxProgressive", "@TaxRate" };
            object[] myValues = new object[] { PITID, TaxStep, FromMoney, ToMoney, TaxProgressive, TaxRate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "DIC_PIT_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid PITID, int TaxStep, decimal FromMoney, decimal ToMoney, decimal TaxProgressive, double TaxRate)
        {
            string[] myParams = new string[] { "@PITID", "@TaxStep", "@FromMoney", "@ToMoney", "@TaxProgressive", "@TaxRate" };
            object[] myValues = new object[] { PITID, TaxStep, FromMoney, ToMoney, TaxProgressive, TaxRate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "DIC_PIT_Insert", myParams, myValues);
        }

        [DisplayName("FromMoney"), Category("Column")]
        public decimal FromMoney
        {
            get
            {
                return this.m_FromMoney;
            }
            set
            {
                this.m_FromMoney = value;
            }
        }

        [Category("Column"), DisplayName("PITID")]
        public Guid PITID
        {
            get
            {
                return this.m_PITID;
            }
            set
            {
                this.m_PITID = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class DIC_PIT";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("TaxProgressive")]
        public decimal TaxProgressive
        {
            get
            {
                return this.m_TaxProgressive;
            }
            set
            {
                this.m_TaxProgressive = value;
            }
        }

        [DisplayName("TaxRate"), Category("Column")]
        public double TaxRate
        {
            get
            {
                return this.m_TaxRate;
            }
            set
            {
                this.m_TaxRate = value;
            }
        }

        [Category("Column"), DisplayName("TaxStep")]
        public int TaxStep
        {
            get
            {
                return this.m_TaxStep;
            }
            set
            {
                this.m_TaxStep = value;
            }
        }

        [Category("Column"), DisplayName("ToMoney")]
        public decimal ToMoney
        {
            get
            {
                return this.m_ToMoney;
            }
            set
            {
                this.m_ToMoney = value;
            }
        }
    }
}

